package boogui.member;


/**
 * 아이디/이메일/핸드폰 중복검사
 */

public class MemberChkService implements IMemberChkService {

	MemberVO mvo = null;
	IMemberChkDAO mcdao = null;
	MemberSQL msql = null;

	public MemberChkService() {
		mvo = new MemberVO();
		mcdao = new MemberChkDAO();
		msql = new MemberSQL();
	}

	// 아이디 중복 검사
	@Override
	public int dupChkId(MemberVO m) {
		int result = 0;
		int length = m.getMemid().length();
		if (mcdao.chkD(msql.getChkIdSQL(), m.getMemid())) {
			result = 1;
		} else if (length == 0) {
			result = 2;
		} else if (length > 12 || length < 4) {
			result = 3;
		} else {
			result = 0;
		}
		return result;
	}

	// 핸드폰 중복 검사
	@Override
	public int dupChkHp(MemberVO m) {
		int result = 0;
		int length = m.getMemhp().length();
		if (mcdao.chkD(msql.getChkHpSQL(), m.getMemhp())) {
			result = 1;
		} else if (length == 0) {
			result = 2;
		} else if (length > 11 || length < 10) {
			result = 3;
		} else {
			result = 0;
		}

		return result;
	}

	// 이메일 중복 검사
	@Override
	public int dupChkEmail(MemberVO m) {
		int result = 0;
		int length = m.getMememail().length();
		if (mcdao.chkD(msql.getChkEmailSQL(), m.getMememail())) {
			result = 1;
		} else if (length == 0) {
			result = 2;
		} else {
			result = 0;
		}

		return result;
	}


}
